package com.didispace;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.AsyncRestTemplate;
import org.springframework.web.client.RestTemplate;

@EnableDiscoveryClient
@SpringBootApplication
// 开启断路器功能
@EnableCircuitBreaker
// 这个注解包含了上述的三个注解
// @SpringCloudApplication
public class RibbonApplication {
	

	@Bean
	// 为RestTemplate增加@LoadBalanced注解：
	@LoadBalanced
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
	
	@Bean
	// 为RestTemplate增加@LoadBalanced注解：
	@LoadBalanced
	public AsyncRestTemplate asyncRestTemplate() {
		return new AsyncRestTemplate();
	}

	public static void main(String[] args) {
		new SpringApplicationBuilder(RibbonApplication.class).web(true).run(args);
	}

}
